import Vue from "vue";
import VueRouter from "vue-router";

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter);

const routes = [
	{
		path: "/",
		redirect: "home",
		meta:{
			name:"首页"
		}
	},
	{
		path: "/login",
		name: "Login",
		meta:{
			name:"登录"
		},
		component: () => import("@/pages/Login/Login.vue")
	},
	{
		path: "/home",
		name: "home",
		component: () => import("@/components/Home.vue"),
		redirect: "homePage",
		children: [
			/**
			 * 主页
			 */
			{
				path: '/homePage',
				name:"homePage",
				component: resolve => require(['@/pages/HomePage/HomePage.vue'], resolve), //
				meta: {
					keepAlive: false, // 不需要被缓存
					title: '首页',
				}
			},
			{
				path: '/table',
				name:"table",
				component: resolve => require(['@/pages/Table/Table.vue'], resolve), //
				meta: {
					keepAlive: false, // 不需要被缓存
					title: 'table表格'
				}
			}
		]
	}
];

const router = new VueRouter({
	routes
});

export default router;
